from django.db import models
from datetime import datetime
# Create your models here.


# 基类
class Base(models.Model):

    # 创建事件
    create_time = models.DateTimeField(default=datetime.now(),null=True)

    class Meta:
        abstract = True



#无限极分类
class Cate(models.Model):

	#分类名称
	name = models.CharField(max_length=500)
	#父id
	pid = models.IntegerField()

	class Meta:
		db_table = 'cate'


# 关注表
class UserFlow(Base):

    # 谁关注
    uid = models.IntegerField()
    # 关注的某个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'userflow'



# 用户评论
class Comment(Base):
    # 评论内容
    content = models.CharField(max_length=200)
    # 评论者
    uid = models.IntegerField()
    # 评论的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'comment'




# 商品表
class Goods(Base):
    # 商品名称
    name = models.CharField(max_length=200)
    # 商品简介
    desc = models.CharField(max_length=500)
    # 商品规格
    parms = models.CharField(max_length=500)
    # 商品头图
    img = models.CharField(max_length=200,null=True)
    # 演示视频
    video = models.CharField(max_length=200,null=True)
    # 价格
    price = models.IntegerField()
    # 关注数
    flow = models.IntegerField(default=0,null=True)
    # 分类Id
    cate_id = models.ImageField()

    class Meta:
        db_table = 'goods'



# 用户类
class User(Base):

    # 用户名
    username = models.CharField(max_length=200)
    # 密码
    password = models.CharField(max_length=200)
    # 头像
    img = models.CharField(max_length=200)
    # 类别  0普通用户 1管理员
    type = models.IntegerField(default=0,null=True)

    # 声明表名
    class Meta:
        db_table = 'user'


# 幻灯片
class Pics(Base):

    # 名称
    title = models.CharField(max_length=200)
    # 链接
    link = models.CharField(max_length=200)
    # 图片
    img = models.CharField(max_length=200)

    class Meta:
        db_table = 'pics'




# 考试  商品表
class Good(Base):
    # 商品名称
    name = models.CharField(max_length=200)
    # 商品简介
    desc = models.CharField(max_length=500)
    # 商品规格
    parms = models.CharField(max_length=500)
    # 商品头图
    img = models.CharField(max_length=200,null=True)
    # 演示视频
    video = models.CharField(max_length=200,null=True)
    # 价格
    price = models.IntegerField()
    # 关注数
    flow = models.IntegerField(default=0,null=True)
    # 分类Id
    cate_id = models.ImageField()

    class Meta:
        db_table = 'good'


# 考试 关注表
class Flow(Base):

    # 都是谁关注的
    uid = models.IntegerField()
    # 关注的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'flow'



